<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="http://connect.facebook.net/zh_TW/all.js"></script>

<script type="text/javascript" src="<?php echo $cdn_url ?>facebox/facebox.js"></script>
<link href="<?php echo $cdn_url ?>facebox/facebox.css" media="screen" rel="stylesheet" type="text/css" />

<script language="javascript">
	var cdn_url = '<?php echo $cdn_url ?>';
	var img_url = '<?php echo $img_url ?>';

	var appid = '183795461665323';
	var p_user = <?php echo $p_user ?>;
	var g_user = <?php echo json_encode($g_user) ?>;
	var surplus = <?php echo $surplus ?>;

	var defaultImg = 'http://static.ak.fbcdn.net/rsrc.php/v1/z9/r/jKEcVPZFk-2.gif';

	<?php include_once 'main.js'; ?>
</script>
<style type="text/css">
	<?php include_once 'main.css'; ?>
</style>
</head>

<body>

<div id="page">
	<?php include_once 'header.html'; ?>
	<div id="content">
		<?php include_once 'main.html'; ?>
	</div>
	<?php include_once 'footer.html'; ?>
</div>

<div id="fb-root"></div>
<script type="text/javascript"><!--
fbloaded = false;
function loadinit() {
	if(fbloaded) return false;
	fbloaded = true;

	FB.api(
		{
			method: 'fql.query',
			query: 'SELECT name, pic, pic_small FROM profile WHERE id=' + FB.getSession().uid
		},
		function(response) {
			log("loadinit|FB.api", response[0]);
			var user = response[0];
			jQuery('#user-info').html('<img src="' + user.pic_small + '"/>').show('fast');
		}
	);

	if(typeof g_user.is_register != null && g_user.is_register == '1') {
		FB.Data.query('SELECT uid, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me());').wait(loaded_friends);
	}

	init_battle();
}

jQuery(document).ready(function(){
	// init
	FB.init({appId: appid, status: true, cookie: true, xfbml: false});
	setTimeout(function(){
	    FB.Canvas.setSize({"height":$("body").height(),"width":760});
	    FB.Canvas.setAutoResize(10);
	},3000);
	FB.Canvas.setAutoResize(10);

	// login / appid; 2311a51fd9f2399d03aed99b4e7e0cd1
	FB.getLoginStatus(function(response) {
		if(response.status != 'connected') {
			FB.Event.subscribe('auth.login', function(response) {
				loadinit();
			});
			FB.login(function(){}, {perms:'email,publish_stream'});
		}
		else {
			loadinit();
		}
	});

	jQuery("#surplus").html(surplus);

	jQuery('#pic-l').click(function() {
		surplus > 0 ? do_battle(0) : overLimit();
	});
	jQuery('#pic-r').click(function() {
		surplus > 0 ? do_battle(1) : overLimit();
	});
});
--></script>

<div style="position: absolute;top:-10000px;">
<form id="reload_form" action="" target="_self" method="post">
<?php foreach($_REQUEST as $n => $req) :?>
<input type="hidden" name="<?php echo $n ?>" value="<?php echo $req ?>" />
<?php endforeach; ?>
</form>
</div>
<div id="track-root" style="height: 1px; position: absolute;top:-10000px;"></div>

<?php if(ujn::getCFG(CFG_IS_ADMIN)) ___INCLUDE('main.admin.php'); ?>

</body>
</html>